
package com.swcn.u_pet;


import java.text.SimpleDateFormat;
import java.util.Date;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;

public class Steps extends View{
	    Stepsfront activity;
	    static int count = 0;
	    static int steps = 0;
	    
	    public Steps(Context context){
	    	super(context);
	    	
	    	activity = (Stepsfront)context;
	    	
	    	setBackgroundColor(Color.rgb(255,255,255));
		}
	    
	public void Count(){
		steps++;
	}
	
	
	    
	protected void onDraw(Canvas canvas){
		count++;
		
		Paint p = new Paint();
		
		p.setAntiAlias(true);
		p.setTextSize(32.0f);
		p.setColor(Color.rgb(0,0,0));
		
		AccelerometerListener listener = activity.getAccelerometerListener();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd '\' hh:mm:ss a ");
		Date date = new Date();
		
		canvas.drawText("AccelX: "+listener.getAccelX(),8,40,p);
		canvas.drawText("AccelY: "+listener.getAccelY(),8,80,p);
		canvas.drawText("AccelZ: "+listener.getAccelZ(),8,120,p);
		canvas.drawText("Azimuth: "+listener.getAzimuth(),8,160,p);
		canvas.drawText("Pitch: "+listener.getPitch(),8,200,p);
		canvas.drawText("Roll: "+listener.getRoll(),8,240,p);
		canvas.drawText("Time:"+sdf.format(date),8,280,p);
		canvas.drawText("Steps: "+steps,8,320,p);
		canvas.drawText("Distance: "+steps*60,8,360,p);
		canvas.drawText("Count:"+count,8,400,p);

	}
}
//	    Stepsfront activity;
//	    static int steps = 0;
//	    
//	    
//	    public Steps(Context context){
//	    	super(context);
//	    	
//	    	activity = (Stepsfront)context;
//	    	
//	    	setBackgroundColor(Color.rgb(255,255,255));
//		}
//	    
////	    public void Count(){
////	    	steps++;
////	    }
//	    
//	protected void onDraw(Canvas canvas){
//		
//		Paint p = new Paint();
//		
//		p.setAntiAlias(true);
//		p.setTextSize(32.0f);
//		p.setColor(Color.rgb(0,0,0));
//		
////		AccelerometerListener listener = activity.getAccelerometerListener();
//		SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd '\' hh:mm:ss a ");
//		Date date = new Date();
//		
//		canvas.drawText("Steps: "+steps,8,40,p);
//		canvas.drawText("Distance: "+steps*60,8,80,p);
//		canvas.drawText("Time: "+sdf.format(date),8,120,p);
//
//	}
//}